"""
sigmoid函数
relu函数
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches

plt.figure(figsize=(10,5))

# 创建数据x
x = np.arange(-10,10,0.1)

# 计算sigmoid函数
s = 1.0/(1 + np.exp(0. - x))

# 计算Relu函数
y = np.clip(x,a_min=0,a_max=None)

# 画图
f = plt.subplot(121)
plt.plot(x,s,color='r')
currentAxis = plt.gca() # 获取当前坐标轴
plt.text(-9.0,0.9,r'$y=Sigmoid(x)$',fontsize=13)
currentAxis.xaxis.set_label_text('x',fontsize=15)
currentAxis.yaxis.set_label_text('y',fontsize=15)

f = plt.subplot(122)
plt.plot(x,y,color='g')
plt.text(-3.0,9,r'$y=Relu(x)$',fontsize=13)
currentAxis = plt.gca()
currentAxis.xaxis.set_label_text('x',fontsize=15)
currentAxis.yaxis.set_label_text('y',fontsize=15)

plt.show()


